﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;


namespace RStudio.Elevator
{
    /// <summary>
    /// 模块|电梯参数中心
    /// </summary>
    /// <remarks>
    /// 全局访问所有已有电梯参数配置
    /// </remarks>
    public class ElevatorModuleDetail
    {
        public ElevatorModuleDetail()
        {
            this.DetailList = new HashSet<ElevatorDetail>();
        }

        public HashSet<ElevatorDetail> DetailList { get; private set; }


        /// <summary>
        /// 注册|队列组
        /// </summary>
        public void Register(ElevatorDetail detail)
        {
            var match = Get(detail.Name);
            if (match != null)
            {
                Debug.LogError($"{detail.Name} 命名冲突");
                return;
            }

            this.DetailList.Add(detail);
            Debug.Log($"<b>[ElevatorModuleDetail]</b> {detail.Name} 注册了电梯参数中心");
        }

        /// <summary>
        /// 获取|队列组
        /// </summary>
        public ElevatorDetail Get(string name)
        {
            return this.DetailList.ToList().Find(e => e.Name == name);
        }
    }
}
